package com.cskaoyan.javase._1extends._8hidden;

/**
 * 属性的隐藏举例
 *
 * @since 10:20
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo3 {
    public static void main(String[] args) {
        Phone p = new HuaWeiPhone(6000);
        System.out.println(p.price);

        Phone p2 = new HuaWeiPhone();
        System.out.println(p2.price);

        HuaWeiPhone h1 = new HuaWeiPhone(8000);
        System.out.println(h1.price);

        HuaWeiPhone h2 = new HuaWeiPhone(100, 200);
        System.out.println(h2.price);

        Phone p3 = new HuaWeiPhone(100, 200);
        System.out.println(p3.price);
        System.out.println(((HuaWeiPhone) p3).price);
    }
}

class Phone {
    double price = 1000;

    {
        price = 2000;
    }

    public Phone(double price) {
        this.price = price;
    }

    public Phone() {
    }
}

class HuaWeiPhone extends Phone {
    double price;

    {
        price = 3000;
    }

    public HuaWeiPhone(double price) {
        super(price);
    }

    public HuaWeiPhone() {
    }

    public HuaWeiPhone(double price, double price1) {
        super(price);
        this.price = price1;
    }
}